package com.qing.servicevod.controller;

import com.qing.servicebase.exception.JsonException;
import com.qing.servicebase.utils.ResponseResult;
import com.qing.servicevod.service.VideoService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @ClassName Yjx
 * @Description TODO
 * @date 2022/9/10 22:13
 * @Version 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("/eduvod/video")
public class VideoAdminController {

    private final VideoService videoService;

    public VideoAdminController(VideoService videoService) {
        this.videoService = videoService;
    }

    @PostMapping("/upload")
    public ResponseResult uploadVideo(@RequestParam("file") MultipartFile file) throws Exception {
        return videoService.uploadVideo(file);
    }

    @DeleteMapping("/delete/{videoId}")
    public ResponseResult removeVideo(@PathVariable("videoId") String videoId){
        return videoService.removeVideo(videoId);
    }

    /**
     * 批量删除视频
     * @param videoIdList
     * @return
     */
    @DeleteMapping("/deletebatch")
    public ResponseResult removeVideoList(@RequestParam("videoIdList") List videoIdList){
        return videoService.removeVideoList(videoIdList);
    }
}